//
//  HomeNoticeListCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/5/7.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "HomeNoticeListCell.h"

@interface HomeNoticeListCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *contentLab;

@end

@implementation HomeNoticeListCell

+ (instancetype)HomeNoticeListCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"HomeNoticeListCell";
    HomeNoticeListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[HomeNoticeListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [UIView new];
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 4;
        self.bgView.backgroundColor = HexColor(0xffffff);
        [self.contentView addSubview:self.bgView];
        
        self.timeLab = [UILabel new];
        self.timeLab.textColor = HexColor(0x333333);
        self.timeLab.font = BoldFontOfSize(14);
        [self.bgView addSubview:self.timeLab];
        
        self.contentLab = [UILabel new];
        self.contentLab.textColor = HexColor(0x666666);
        self.contentLab.font = [UIFont systemFontOfSize:12];
        [self.bgView addSubview:self.contentLab];
    }
    return self;
}

-(void)setModel:(HomeNoticeModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 10;
    self.bgView.nim_width = ScreenW - 2 * 15;
    
    self.timeLab.nim_left = 10;
    self.timeLab.nim_top = 10;
    self.timeLab.nim_width = self.bgView.nim_width - 2 * self.timeLab.nim_left;
    self.timeLab.text = self.model.create_time;
    [self.timeLab sizeToFit];
    
    self.contentLab.nim_left = 10;
    self.contentLab.nim_top = self.timeLab.nim_bottom + 5;
    self.contentLab.nim_width = self.bgView.nim_width - 2 * self.contentLab.nim_left;
    self.contentLab.text = self.model.title;
    [self.contentLab sizeToFit];
    
    self.bgView.nim_height = self.contentLab.nim_bottom + 10;
    self.height = self.bgView.nim_bottom;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
